<template>
  <div class="container">
    <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
      <div
        ref="fresh"
        :style="{height:Height +'px','overflow-y':'scroll','box-sizing': 'border-box','padding-bottom':'0.2rem'}"
      >
        <div class="pro" v-for="(item,index) in proList" :key="'item'+index">
          <div class="protitle">{{item.productName}}</div>
          <div>年利率</div>
          <div>
            <div>{{item.interestRate}}</div>
            <div>
              <van-button type="default" color="#DBB47F" class="btn" @click="shenqing(item)">立即申请</van-button>
            </div>
          </div>
        </div>
      </div>
    </van-pull-refresh>
  </div>
</template>
<script>
import { Toast } from "vant";
import Api from "./../api/api";
export default {
  data() {
    return {
      isLoading: false,
      Height: "",
      proList: []
    };
  },
  methods: {
    onRefresh() {
      setTimeout(() => {
        this.getproList();
        this.isLoading = false;
      }, 1000);
    },
    getproList() {
      this.$axios
        .get(`${Api.HTTP.product}?pageSize=0&pageNo=0`)
        .then(res => {
          this.proList = [];
          this.proList = res.data;
          Toast("加载成功");
        })
        .catch(function(error) {
          Toast("网络错误");
        });
    },
    shenqing(item){
           this.$router.push({
          path: "/ProductDetail",
          query: {
            item: item
          }
        });
    }
  },
  mounted() {
    this.pubilcM.setTitle("产品列表");
    this.Height = document.documentElement.clientHeight;
    this.getproList();
  }
};
</script>
<style scoped>
.container {
  width: 100%;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  background: #f6f5f5;
}
.pro {
  padding: 0.2rem;
  background: #fff;
  margin-bottom: 0.2rem;
}
.protitle {
  font-size: 0.4rem;
}
.pro div:nth-child(2) {
  font-size: 0.23rem;
  color: #999999;
  margin-top: 0.1rem;
}
.pro div:nth-child(3) {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.1rem;
}
.pro div:nth-child(3) div:nth-child(1) {
  font-size: 0.4rem;
  color: #dbb47f;
  /* #DBB47F */
}
.btn {
  width: 1.8rem;
  height: 0.7rem;
  line-height: 0.7rem;
}
</style>